package com.neu.admin;

import com.neu.service.ShoppingSystemService;
import com.neu.util.response.BaseResponse;
import com.neu.vo.ShoppingSystemVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 配置管理
 */
@RestController
@RequestMapping("/admin/config")
public class AdminSystemController {
    @Autowired
    private ShoppingSystemService shoppingSystemService;;
//    @RequiresPermissions("admin:config:wx")
    @GetMapping("/wx")
    @ApiOperation(value="获取配置列表")
    public ResponseEntity<BaseResponse<ShoppingSystemVo>> listWx() {
        Map<String, Object> data = shoppingSystemService.listWx();
        return BaseResponse.generateOKResponseEntity(data);
    }
    @GetMapping("/mall")
    @ApiOperation(value="获取列表")
    public ResponseEntity<BaseResponse<ShoppingSystemVo>> listMall() {
        Map<String, Object> data = shoppingSystemService.listMail();
        return BaseResponse.generateOKResponseEntity(data);
    }

    @PostMapping("/updateWx")
    @ApiOperation(value="修改信息")
    public ResponseEntity updateWx(@RequestBody Map<String,String> map){
        int flag = shoppingSystemService.updateConfigWx(map);
        if (flag==1){
            return BaseResponse.generateOKResponseEntity();
        }else {
            return BaseResponse.generateBadResponseEntity();
        }
    }
    @PostMapping("/updateMall")
    @ApiOperation(value="修改信息")
    public ResponseEntity updateMall(@RequestBody Map<String,String> map){
        int flag = shoppingSystemService.updateConfigMall(map);
        if (flag==1){
            return BaseResponse.generateOKResponseEntity();
        }else {
            return BaseResponse.generateBadResponseEntity();
        }
    }
//    @PostMapping("/express")
//    @ApiOperation(value = "运费修改")
//    public ResponseEntity update(@RequestBody Map<String,String> map){
//        int flag = shoppingSystemService.updateConfig(map);
//        if (flag==1){
//            return BaseResponse.generateOKResponseEntity();
//        }else {
//            return BaseResponse.generateBadResponseEntity();
//        }
//    }
}
